package me.eleme.anubis.openapi.config;

import lombok.extern.slf4j.Slf4j;

import me.eleme.anubis.openapi.utils.StringUtils;

/**
 * @author  liuzhiyong
 */
@Slf4j
public class Config {
    /**
     * 应用app id
     */
    private String appId;
    /**
     * 应用秘钥
     */
    private String secretKey;

    /**
     * 域名
     */
    private String serverUrl;
    /**
     * 鉴权接口url
     */
    private String oauthApiUrl;
    /**
     * 请求url
     */
    private String postUrl;
    /**
     * 业务接口 base url
     */
    private String bizApiUrl;

    public Config(boolean isSandbox, String appKey, String appSecret) {
        if (StringUtils.areNotEmpty(appKey, appSecret)) {
        } else {
            log.error("appKey and appSecret is required.");
        }
        appId = appKey;
        secretKey = appSecret;
        if (isSandbox) {
            serverUrl = BasicUrl.SANDBOX_SERVER;
            oauthApiUrl = BasicUrl.OpenApi.SANDBOX_API;
            bizApiUrl = BasicUrl.OpenApi.BIZ_URL_SANDBOX_API;
        } else {
            serverUrl = BasicUrl.PRODUCTION_SERVER;
            oauthApiUrl = BasicUrl.OpenApi.PRODUCTION_API;
            bizApiUrl = BasicUrl.OpenApi.BIZ_URL_PRODUCTION_API;
        }
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getServerUrl() {
        return serverUrl;
    }

    public void setServerUrl(String serverUrl) {
        this.serverUrl = serverUrl;
    }

    public String getOauthApiUrl() {
        return oauthApiUrl;
    }

    public void setOauthApiUrl(String oauthApiUrl) {
        this.oauthApiUrl = oauthApiUrl;
    }

    public String getPostUrl() {
        return postUrl;
    }

    public void setPostUrl(String postUrl) {
        this.postUrl = postUrl;
    }

    public String getBizApiUrl() {
        return bizApiUrl;
    }

    public void setBizApiUrl(String bizApiUrl) {
        this.bizApiUrl = bizApiUrl;
    }
}
